<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Home extends CI_Controller {

    public $scraper;
    public $static_mode = FALSE; // use downloaded html page instead of online page or not

	function __construct()
	{
		parent::__construct();

		$this->load->library('domparser');
        $this->load->library('Deal');
        $this->load->library('Scraper');
        
        $this->scraper = new Scraper();
	}

	function index()
	{
        $url = $this->static_mode ? 'static/phagia.html'
                : 'http://phagia.com.vn/tp-ho-chi-minh/pha-gia-giam-gia-sieu-khuyen-mai-hom-nay';

        $data['deals'] = $this->scraper->extract($url, Scraper::TARGET_PHAGIA);

		$this->load->view('home_view', $data);
	}
}

/* End of file home.php */
/* Location: ./application/controllers/home.php */